<%-- 
    Document   : checkorders
    Created on : Jul 4, 2011, 12:57:21 AM
    Author     : PhongLK60473
--%>

<%@page import="java.util.Enumeration"%>
<%@page import="java.util.Hashtable"%>
<%@page import="Object.CustomerOrder"%>
<%@page import="Object.Page"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <style type="" >
            @import url("style/style.css");
            @import url("style/checkorders.style.css");
        </style>
    </head>
    <body>
        <%@include file="header.jsp" %>
        <%%>
        <%
                    if (!user.isAdmin()) {
                        response.sendRedirect("UserController");
                    }
        %>
        <div id="page">

        <% if(Page.isMessage(request)){ %>
            <div class="message"><%= Page.getMessage(request) %></div>
        <% } %>
        <h1>Check Orders</h1>
        
        <%
            CustomerOrder[] orders = CustomerOrder.getAllOrders(-1);
            
        %>
        <table border="1" class="orders">
                <thead>
                    <tr class="title">
                        <th class="No">No.</th>
                        <th class="DateTime">Date | Time</th>
                        <th class="TotalPrice">TotalPrice</th>
                        <th class="Customer">Customer</th>
                        <th class="Status">Status</th>
                        <th class="Action">Action</th>
                    </tr>
                </thead>
                <tbody>
                    <%
                    Hashtable Status = CustomerOrder.HStatus;
                    System.out.println(orders.length);
                    for(int i=0;i<orders.length;i++){
                        CustomerOrder order=(CustomerOrder)orders[i];
                    %>
                    <tr class="data">
                        <td class="Id"><%= (i+1) %></td>
                        <td class="DateTime">
                            <%= order.getDate() %> |
                            <%= order.getTime() %>
                        </td>
                        <td class="TotalPrice"><%= order.getTotalPrice() %></td>
                        <td class="Customer"><%= order.getUserObj().getUsername() %></td>
                        <td class="Status">
                            <form action="ManagerController" method="POST">
                            <input type="hidden" name="action" value="ChangeStatus"/>
                            <input type="hidden" name="orderid" value="<%= order.getId() %>"/>
                            <select name="statusid" onchange="this.form.submit()">
                                 <%
                                 Enumeration eStt = Status.keys();
                                 while(eStt.hasMoreElements()){
                                     int key=Integer.parseInt(eStt.nextElement().toString());
                                     String value=Status.get(""+key).toString();
                                     %>
                                     <option value="<%= key %>" <%= (key==order.getStatusId())?"selected":"" %>><%= value %></option>
                                     <%
                                 }
                                 %>
                            </select>
                            </form>
                        </td>
                        <td class="Action">
                            <!--
                            <a href="ManagerController?action=EditBook&bookid="><img src="images/icon_edit_book.png"/></a>
                            <a href="ManagerController?action=DeleteBook&bookid="><img src="images/icon_delete_book.jpg"/></a>
                            -->
                        </td>
                    </tr>
                    <%
                    }
                    %>
                </tbody>
            </table>
        </div>
    </body>
</html>
